home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 9.7 KB | 287 lines | [TEXT/MPS ] |
- // UDesignator.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UDESIGNATOR__
- #define __UDESIGNATOR__
-
- //----------------------------------------------------------------------------------------
- // OVERVIEW
- // ========
- // TDesignator is designed as an abstract superclass which designates a portion of the
- // document. Each specialized document will require its own specialized designator.
- // Specialized subclasses of TDesignator are required to designate portions of different
- // documents.
- //
- // CLASS HIERARCHY
- // ===============
- // TDesignator abstract superclass for designators
- // TLinearDesignator a linear data designator (e.g. for text models)
- // TRectDesignator a rectangular designator (e.g. for spreadsheet models)
- // TRgnDesignator a region designator (e.g. for discontiguous designations)
- //
- // USAGE
- // =====
- // TDesignator is used with the Edition Manager support that is built into MacApp.
- // Whenever a TSection object is instantiated, it requires a TDesignator object that lets
- // the TSection object determine which portion of the document is being designated as a
- // section, whether a publisher or a subscriber.
- //----------------------------------------------------------------------------------------
-
- // MacApp
-
- #ifndef __UGEOMETRY__
- #include "UGeometry.h"
- #endif
-
- #ifndef __UOBJECT__
- #include "UObject.h"
- #endif
-
- #ifndef __USCRIPTABLEOBJECT__
- #include "UScriptableObject.h"
- #endif
-
- // Toolbox
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Containment constants
- //----------------------------------------------------------------------------------------
-
- enum ContainmentType { kNotContained, kPartiallyContained, kExactlyContained, kFullyContained };
-
- //----------------------------------------------------------------------------------------
- // Object Signtures: These follow the same reservation rules as resource types. The
- // signature is used to search the signature table and create an object "by signature"If
- // the signature's entry in the table has been updated with a new class then an object of
- // that class will be created.
- //----------------------------------------------------------------------------------------
-
- const IDType kLinearDesignator = 'ldsg';
-
- const IDType kVRectDesignator = 'vdsg';
-
- const IDType kRegionDesignator = 'rdsg';
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TStream;
-
- //----------------------------------------------------------------------------------------
- // TDesignator: is designed as an abstract superclass. Use subclasses of TDesignator.
- //----------------------------------------------------------------------------------------
-
- class TDesignator : public TObject, public MScriptableObject
- {
- MA_DECLARE_CLASS;
-
- public:
- //----------------------------------------------------------------------------------------
- // • contructors/destructors
- //----------------------------------------------------------------------------------------
-
- TDesignator();
- // Empty constructor to satisfy compiler.
- virtual ~TDesignator();
- // Destructor
-
- void IDesignator();
- // initialize this object
-
- //----------------------------------------------------------------------------------------
- // • utility methods
- //----------------------------------------------------------------------------------------
-
- virtual Size GetSize();
- // returns the size of this designation
-
- virtual ContainmentType IsContained(TDesignator* aDesignator);
- // Override this; returns a ContainmentType indicating to what extent aDesignator
- // is contained in this
-
- virtual Boolean IsEmpty();
- // Returns false if the size of this designation is greater than 0
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TLinearDesignator: is designed to designate any linear portion of data that may be
- // designated by a start position and an end position.
- //----------------------------------------------------------------------------------------
-
- class TLinearDesignator : public TDesignator
- {
- MA_DECLARE_CLASS;
-
- public:
- long fStartPos; // offset to start
-
- long fEndPos; // offset to end
-
- //----------------------------------------------------------------------------------------
- // • contructors/ destructors
- //----------------------------------------------------------------------------------------
-
- TLinearDesignator();
- // Constructor
- virtual ~TLinearDesignator();
- // Destructor
-
- void ILinearDesignator(long startPos,
- long endPos);
- // initialize this object
-
- //----------------------------------------------------------------------------------------
- // • utility methods
- //----------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature();
- // returns the signature for this class
-
- virtual Size GetSize();
- // returns the size of this designation
-
- virtual ContainmentType IsContained(TDesignator* aDesignator);
- // OVERRIDE this; returns a ContainmentType indicating to what extent aDesignator
- // is contained in this
-
- //----------------------------------------------------------------------------------------
- // • saving
- //----------------------------------------------------------------------------------------
-
- virtual void WriteTo(TStream* aStream);
- // OVERRIDE this; writes specification of designator to stream
-
- virtual void ReadFrom(TStream* aStream);
- // initializes this object from a stream specification
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TVRectDesignator: is designed to designate any rectangular portion of data that may be
- // designated by top, left, bottom, and right VCoordinates.
- //----------------------------------------------------------------------------------------
-
- class TVRectDesignator : public TDesignator
- {
- MA_DECLARE_CLASS;
-
- public:
- VRect fDesignation; // VRect representing designation
-
- //----------------------------------------------------------------------------------------
- // • contructors/destructors
- //----------------------------------------------------------------------------------------
-
- TVRectDesignator();
- // Constructor
- virtual ~TVRectDesignator();
- // Destructor
-
- void IVRectDesignator(const VRect& itsDesignation);
- // initialize this object
-
- //----------------------------------------------------------------------------------------
- // • utility methods
- //----------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature();
- // returns the signature for this class
-
- virtual Size GetSize();
- // returns the size of this designation
-
- virtual ContainmentType IsContained(TDesignator* aDesignator);
- // OVERRIDE this; returns a ContainmentType indicating to what extent aDesignator
- // is contained in this
-
- //----------------------------------------------------------------------------------------
- // • saving
- //----------------------------------------------------------------------------------------
-
- virtual void WriteTo(TStream* aStream);
- // OVERRIDE this; writes specification of designator to stream
-
- virtual void ReadFrom(TStream* aStream);
- // initializes this object from a stream specification
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TRegionDesignator: is designed to designate any portion of data that may be designated by
- // a region. The caller must create the region, and the designator optionally frees the
- // region. In general, the TStream passed into this object should be a THandleStream.
- //----------------------------------------------------------------------------------------
-
- class TRegionDesignator : public TDesignator
- {
- MA_DECLARE_CLASS;
-
- public:
- RgnHandle fDesignation; // rgn representing designation
-
- Boolean fFreeRegionOnFree; // whether to free the RgnHandle when this
- // designator is freed
-
- //----------------------------------------------------------------------------------------
- // • contructors/destructors
- //----------------------------------------------------------------------------------------
-
- TRegionDesignator();
- // Constructor
-
- void IRegionDesignator(RgnHandle itsDesignation,
- Boolean freeRegionOnFree);
- // Initialize this object.
-
- virtual ~TRegionDesignator();
- // Frees fDesignation and calls Inherited::Free.
-
- virtual TObject* Clone();
- // Calls Inherited::Clone, creates a copy of fDesignation rgn.
-
-
- //----------------------------------------------------------------------------------------
- // • utility methods
- //----------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature();
- // returns the signature for this class
-
- virtual Size GetSize();
- // returns the size of this designation
-
- virtual ContainmentType IsContained(TDesignator* aDesignator);
- // returns a ContainmentType indicating to what extent aDesignator is contained in this
-
- virtual void SetDesignationRect(const CRect& theDesignation);
- // sets fDesignation to contain this rectangle
-
- //----------------------------------------------------------------------------------------
- // • saving
- //----------------------------------------------------------------------------------------
-
- virtual void WriteTo(TStream* aStream);
- // OVERRIDE this; writes specification of designator to stream
-
- virtual void ReadFrom(TStream* aStream);
- // initializes this object from a stream specification
- };
-
-
- #endif
-
-
-